//
//  CTSlideInPresentationManager.swift
//  Swift-Tools
//
//  Created by gree on 2020/10/16.
//

import UIKit
import Foundation

enum CTPresentationDirection {

    case top(width: CGFloat = UIScreen.main.bounds.size.width, height: CGFloat = UIScreen.main.bounds.size.height/2)
    case left(width: CGFloat = UIScreen.main.bounds.size.width/2, height: CGFloat = UIScreen.main.bounds.size.height)
    case bottom(width: CGFloat = UIScreen.main.bounds.size.width, height: CGFloat = UIScreen.main.bounds.size.height/2)
    case right(width: CGFloat = UIScreen.main.bounds.size.width/2, height: CGFloat = UIScreen.main.bounds.size.height)
}

class CTSlideInPresentationManager: NSObject {

    /// 设置入场方向
    var direction: CTPresentationDirection = .bottom()
    var disableCompactHeight = false
}

extension CTSlideInPresentationManager: UIViewControllerTransitioningDelegate {
    
    func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
        let presentationController = CTPresentationController(presentedViewController: presented, presenting: presenting, direction: direction)
        return presentationController
    }
}

//extension CTSlideInPresentationManager: UIAdaptivePresentationControllerDelegate {
//    func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
//        if traitCollection.verticalSizeClass == .compact && disableCompactHeight {
//            return .overFullScreen
//        } else {
//            return .none
//        }
//    }
//
//    func presentationController(_ controller: UIPresentationController, viewControllerForAdaptivePresentationStyle style: UIModalPresentationStyle) -> UIViewController? {
//        guard case(.overFullScreen) = style else {
//            return nil
//        }
//        return UIViewController()
//    }
//}

